﻿using System;
using MetroGA.Core.Hits;
using Newtonsoft.Json;

namespace MetroGA.Wp8
{
	internal class HitTypeBinder : SerializationBinder
	{
		public override Type BindToType(string assemblyName, string typeName)
		{
			if (typeName.Contains("ViewHit"))
				return typeof(ViewHit);
			if (typeName.Contains("EventHit"))
				return typeof(EventHit);
			if (typeName.Contains("ExceptionHit"))
				return typeof(ExceptionHit);
			if (typeName.Contains("TimingHit"))
				return typeof(TimingHit);
			if (typeName.Contains("SocialHit"))
				return typeof(SocialHit);

			return null;
		}

		public override void BindToName(Type serializedType, out string assemblyName, out string typeName)
		{
			assemblyName = String.Empty;
			typeName = serializedType.FullName;
		}
	}
}